class SetCssVal {
    private style: any = null;
    // 设置css变量
    public setCssVal(key: string, val: string) {
        if (!this.style) {
            this.init();
        }
        this.style.setProperty(key, val);
    }
    // 设置多个 css变量
    public setCssVals(vals: object = {}) {
        if (!this.style) {
            this.init();
        }
        type valType = keyof typeof vals;
        Object.keys(vals).map((key: any) => {
            this.style.setProperty(key, vals[key as valType]);
        });
    }
    // 初始化
    private init() {
        this.style = document.getElementsByTagName("body")[0].style;
    }
}

const setCssVal: SetCssVal = new SetCssVal();
export default setCssVal;
